#include "Utils.h"
#include "ListNode.h"
#include "TreeNode.h"
#include <iostream>
#include <vector>
#include <string>
#include <sstream>

using namespace std;

class Issue257 {
public:
	vector<string> binaryTreePaths(TreeNode* root) {
		vector<string> res;
		if (root!=NULL)
			binaryTreePaths("",root,&res);
		return res;
	}

private:
	void binaryTreePaths(string prefix,TreeNode* root,vector<string>* result){

		std::stringstream sstm;
		if (prefix!="")
			sstm << prefix <<"->";
		sstm<<root->val;
		
		prefix=sstm.str();

		if (root->right==NULL&&root->left==NULL)
			result->push_back(prefix);
		else
		{
			if (root->left!=NULL)
				binaryTreePaths(prefix,root->left,result);
			if (root->right!=NULL)
				binaryTreePaths(prefix,root->right,result);
		}
		
	}
};

int main257(){

	Issue257 sol;

	TreeNode* root=new TreeNode(1);
	TreeNode* node1=new TreeNode(2);
	TreeNode* node2=new TreeNode(3);
	TreeNode* node3=new TreeNode(4);

	//root->left=node1;
	//root->right=node2;
	//root->left->left=node3;

	vector<string> res=sol.binaryTreePaths(root);

	for (int i=0;i<res.size();++i)
	{
		cout<<res[i]<<endl;
	}

	return 0;
}